﻿using Microsoft.Xna.Framework.Graphics;
using ShevaEngine2.Modules.Animations;

namespace ShevaEngine.Core.Modules.Materials
{
    /// <summary>
    /// Animations parameters.
    /// </summary>
    public class GraphicsMaterialParameterAnimations : GraphicsMaterialParameter
    {
        /// <summary>Animation data.</summary>
        private AnimationPlayer AnimationPlayer;        

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="animationPlayer"></param>
        public GraphicsMaterialParameterAnimations(string name, AnimationPlayer animationPlayer)
            : base(name)
        {
            this.AnimationPlayer = animationPlayer;            
        }

        /// <summary>
        /// Method sets values.
        /// </summary>
        /// <param name="material"></param>
        public override void Set(GraphicsMaterial material)
        {
            material.Effect.Parameters[this.Name].SetValue(this.AnimationPlayer.AnimationTransforms);
        }

        /// <summary>
        /// Method sets values.
        /// </summary>
        /// <param name="material"></param>
        public void Set(Effect effect)
        {
            effect.Parameters[this.Name].SetValue(this.AnimationPlayer.AnimationTransforms);
        }
    }
}
